#include<bits/stdc++.h>
#define ll long long 
#define Int __int128
using namespace std;
namespace IO{
    char buff[1<<21],*p1=buff,*p2=buff;
    char getch(){
        return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;
    }
    template<typename T>
    void read(T &x){
        char ch=getch();int fl=1;x=0;
        while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getch();}
        while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getch();}
        x*=fl;
    }
    template<typename T,typename ...Args>
    void read(T &x,Args& ...args){
        read(x);read(args...);
    }
    char obuf[1<<21],*p3=obuf;
    void putch(char ch){
        if(p3-obuf<(1<<21))*p3++=ch;
        else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
    }
    char ch[100];
    template<typename T>
    void write(T x){
        if(!x)return putch('0');
        if(x<0)putch('-'),x*=-1;
        int top=0;
        while(x)ch[++top]=x%10+48,x/=10;
        while(top)putch(ch[top]),top--;
    }
    template<typename T,typename ...Args>
    void write(T x,Args ...args){
        write(x);write(args...);
    }
    void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
const int N=2e6+5;
int n,m;
int a[N],maxn[N],s[N];
ll b[N];
Int calc(int x){
    if(x<0)return 0;
    s[m]=x;
    for(int i=m+1;i<=n-m+1;i++)s[i]=min(maxn[i],a[i-1]-s[i-1]);
    for(int i=m-1;i>=1;i--)s[i]=min(maxn[i],a[i]-s[i+1]);
    for(int i=n-m+2;i<=n;i++)s[i]=min(maxn[i],a[i-1]-s[i-1]);
    Int ans=0;
    for(int i=1;i<=n;i++)ans+=(Int)s[i]*b[i];
    return ans;
}
void sol(){
    read(n,m);
    for(int i=1;i<n;i++)read(a[i]);
    fill(b+1,b+n+1,0);
    for(int i=1;i<=m;i++){
        int x;
        read(x);
        b[i]+=x;
        b[n-m+1+i]-=x;
    }
    for(int i=2;i<=n;i++)b[i]+=b[i-1];
    for(int i=1;i<n;i++)maxn[i]=a[i];maxn[n]=a[n-1];
    for(int i=2;i<n;i++)maxn[i]=min(maxn[i],a[i-1]);
    Int ans=0;
    int l=0,r=maxn[m];
    while(l<r){
        int mid=((l+r+1)>>1);
        Int delta=calc(mid)-calc(mid-1);
        if(delta>0)l=mid;
        else r=mid-1;
    }
    ans=max(ans,calc(l));
    l=0,r=maxn[m];
    while(l<r){
        int mid=((l+r+1)>>1);
        Int delta=calc(mid)-calc(mid-1);
        if(delta>=0)l=mid;
        else r=mid-1;
    }
    ans=max(ans,calc(l));
    write(ans),putch('\n');
}
signed main(){
    freopen("festival.in","r",stdin);
    freopen("festival.out","w",stdout);
    int c,t;
    read(c,t);
    while(t--)sol();
    flush();
    return 0;
}